N = 1001;
dp = [];
for (var i = 0; i < N; i++) {
    dp[i] = [];
}

for (var i = 1; i < N; i++) {
    dp[i][i] = 1;
}

for (var i = 2; i < N; i++) {
    for (var j = 1; j < i; j++) {
        dp[i][j] = 0;
        for (var k = j; k <= i - j; k++) {
            dp[i][j] += dp[i - j][k];
        }
    }
}

console.log('starting');

var mod = 1000000;
for (var i = 5; i < N; i++) {
    var sum = 0;
    for (var j = 1; j < i; j++) {
        sum += dp[i][j];
        sum %= mod;
    }
    if (sum === 0) {
        console.log(i);
        process.exit();
    }
}

console.log('done');
